package com.jinzhi.common.utils.wx;

import java.net.InetAddress;
import java.util.Map;

/*
 * 用户发起统一下单请求
 * 作者：董志平
 * 用于发起微信扫码支付接口
 */
public class WXRequestUtil {
	private static String WXSign = null;
	//	//测试
	public static void main(String[] args) {
		//Map<String,String> res = SendPayment("苹果","20170106113325",1,0);
	}

	/**
	 * 获取签名
	 * @return
	 */
	public static String getWXSign() {
		return WXSign;
	}

	/**
	 * 获取时间戳
	 */
	public static String GetTimeStamp(){
		int t = (int)(System.currentTimeMillis()/1000);
		return t+"";
	}


	/**
	 * 	获取用户的ip
	 *
	 */
	public static String GetIp() {
		InetAddress ia=null;
		try {
			ia=InetAddress.getLocalHost();
			String localip=ia.getHostAddress();
			return localip;
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 *
	 * Map转xml数据
	 */
	public static String GetMapToXML(Map<String,String> param){
		StringBuffer sb = new StringBuffer();
		sb.append("<xml>");
		for (Map.Entry<String,String> entry : param.entrySet()) {
			sb.append("<"+ entry.getKey() +">");
			sb.append(entry.getValue());
			sb.append("</"+ entry.getKey() +">");
		}
		sb.append("</xml>");
		return sb.toString();
	}
}
